package core.util;

import java.io.Closeable;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URLConnection;

import org.dom4j.io.XMLWriter;

public class IoUtils {
	
	private IoUtils(){
		
	}

	private static org.apache.log4j.Logger log = Logger.getLogger(IoUtils.class);

	public static void close(XMLWriter writer) {
		try {
			if (writer != null) {
				writer.close();
			}
		} catch (IOException ioe) {
            log.error("流关闭异常", ioe);
		}
	}

	public static void close(Closeable closeable) {
		try {
			if (closeable != null) {
				closeable.close();
			}
		} catch (IOException ioe) {
            log.error("流关闭异常", ioe);
		}
	}
	
	public static void close(URLConnection conn){
        if (conn instanceof HttpURLConnection) {
            ((HttpURLConnection) conn).disconnect();
        }
	}

}
